<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Overview</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intro.mysqlnd.html">简介</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlnd.install.html">Installation</a></div>
 <div class="up"><a href="book.mysqlnd.html">Mysqlnd</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqlnd.overview" class="chapter">
 <h1>Overview</h1>

 <p class="para">
  <em class="emphasis">What it is not</em>
 </p>
 <p class="para">
  Although MySQL Native Driver is written as a PHP extension, it is
  important to note that it does not provide a new API to the PHP
  programmer. The programmer APIs for MySQL database connectivity are
  provided by the MySQL extension, <em>mysqli</em> and PDO
  MYSQL. These extensions can now use the services of MySQL Native
  Driver to communicate with the MySQL Server. Therefore, you should not
  think of MySQL Native Driver as an API.
 </p>
 <p class="para">
  <em class="emphasis">Why use it?</em>
 </p>
 <p class="para">
  Using the MySQL Native Driver offers a number of advantages over using
  the MySQL Client Library.
 </p>
 <p class="para">
  The older MySQL Client Library was written by MySQL AB (now Oracle 
  Corporation) and so was released under the MySQL license. This
  ultimately led to MySQL support being disabled by default in PHP.
  However, the MySQL Native Driver has been developed as part of the PHP
  project, and is therefore released under the PHP license. This removes
  licensing issues that have been problematic in the past.
 </p>
 <p class="para">
  Also, in the past, you needed to build the MySQL database extensions
  against a copy of the MySQL Client Library. This typically meant you
  needed to have MySQL installed on a machine where you were building
  the PHP source code. Also, when your PHP application was running, the
  MySQL database extensions would call down to the MySQL Client library
  file at run time, so the file needed to be installed on your system.
  With MySQL Native Driver that is no longer the case as it is included
  as part of the standard distribution. So you do not need MySQL
  installed in order to build PHP or run PHP database applications.
 </p>
 <p class="para">
  Because MySQL Native Driver is written as a PHP extension, it is
  tightly coupled to the workings of PHP. This leads to gains in
  efficiency, especially when it comes to memory usage, as the driver
  uses the PHP memory management system. It also supports the PHP memory
  limit. Using MySQL Native Driver leads to comparable or better
  performance than using MySQL Client Library, it always ensures the
  most efficient use of memory. One example of the memory efficiency is
  the fact that when using the MySQL Client Library, each row is stored
  in memory twice, whereas with the MySQL Native Driver each row is only
  stored once in memory.
 </p>
 <blockquote class="note"><p><strong class="note">Note</strong>: 
  <strong>Reporting memory usage</strong><br />
  <p class="para">
   Because MySQL Native Driver uses the PHP memory management system, its
   memory usage can be tracked with <span class="function"><a href="function.memory-get-usage.html" class="function">memory_get_usage()</a></span>.
   This is not possible with libmysqlclient because it uses the C function malloc()
   instead.
  </p>
 </p></blockquote>
 <p class="para">
  <em class="emphasis">Special features</em>
 </p>
 <p class="para">
  MySQL Native Driver also provides some special features not available
  when the MySQL database extensions use MySQL Client Library. These
  special features are listed below:
 </p>
 <ul class="itemizedlist">
  <li class="listitem">
   <p class="para">
    Improved persistent connections
   </p>
  </li>
  <li class="listitem">
   <p class="para">
    The special function <span class="function"><a href="mysqli-result.fetch-all.html" class="function">mysqli_fetch_all()</a></span>
   </p>
  </li>
  <li class="listitem">
   <p class="para">
    Performance statistics calls:
    <span class="function"><a href="mysqli.get-cache-stats.html" class="function">mysqli_get_cache_stats()</a></span>,
    <span class="function"><a href="mysqli.get-client-stats.html" class="function">mysqli_get_client_stats()</a></span>,
    <span class="function"><a href="mysqli.get-connection-stats.html" class="function">mysqli_get_connection_stats()</a></span>
   </p>
  </li>
 </ul>
 <p class="para">
  The performance statistics facility can prove to be very useful in
  identifying performance bottlenecks.
 </p>
 <p class="para">
  MySQL Native Driver also allows for persistent connections when used
  with the <em>mysqli</em> extension.
 </p>
 <p class="para">
  <em class="emphasis">SSL Support</em>
 </p>
 <p class="para">
  MySQL Native Driver has supported SSL since PHP version 5.3.3 
 </p>
 <p class="para">
  <em class="emphasis">Compressed Protocol Support</em>
 </p>
 <p class="para">
  As of PHP 5.3.2 MySQL Native Driver supports the compressed client
  server protocol. MySQL Native Driver did not support this in 5.3.0 and
  5.3.1. Extensions such as <em>ext/mysql</em>,
  <em>ext/mysqli</em>, that are configured to use MySQL Native Driver, 
  can also take advantage of this feature. Note that <em>PDO_MYSQL</em> 
  does <em class="emphasis">NOT</em> support compression when used together with mysqlnd.
 </p>
 <p class="para">
  <em class="emphasis">Named Pipes Support</em>
 </p>
 <p class="para">
  Named pipes support for Windows was added in PHP version 5.4.0. 
 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intro.mysqlnd.html">简介</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlnd.install.html">Installation</a></div>
 <div class="up"><a href="book.mysqlnd.html">Mysqlnd</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
